<%--
  Created by IntelliJ IDEA.
  User: 86187
  Date: 2021/10/21
  Time: 10:51
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form" %>



<html>
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>login</title>
    <link href="/resource/css/bootstrap.css" rel="stylesheet">
    <script type="text/javascript" src="/resource/js/jquery-3.2.1.js"></script>

</head>
<body  >

<div class="text-center">
<h3>用户登录</h3>

 <form:form action="/login" method="post" modelAttribute="user">
     用户名:<form:input path="username" />
     <!--错误提示-->
     <form:errors path="username" cssClass="text-danger"></form:errors>
     <br>
     密码:<%--<form:password path="password"   ></form:password>--%>
     <input type="password" name="password" value="${user.password}">
     <form:errors path="password" cssClass="text-danger"></form:errors>

     <br>
     <br>
   <input type="checkbox" name="flag" value="1">十天内免登录
    <button type="submit">登录</button><br>
     没有账户去<a href="/reg">注册</a>
     <br>
     <span class="text-danger">${loginMsg}</span>
 </form:form>

    <script>
        $(function (){
            //如果用户名和密码有值，则自动提交表单
            var username=$("[name='username']").val();
            var password=$("[name='password']").val();
            if( username!=null && username!="" &&password!=null && password!=""){
                $("form").submit();
            }
        })
    </script>
</div>
</body>
</html>
